package org.csu.sei.persistence;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.csu.sei.entity.Category;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CategoryMapper extends BaseMapper<Category> {
    @Select("select max(sort_order) from category")
    int selectMax();

    @Select("select max(sort_order) from category where parent_id=#{parentId}")
    int selectMaxByParentId(Long parentId);

    @Select("select * from category where parent_id=0 and title_id is null")
    List<Category> getTitleNullFirstCategory();

    @Select("select name from category where id=#{id}")
    String getName(Long id);
}

